package org.leviatan.definator.client.local;

import java.util.Collection;
import java.util.Map;

import org.leviatan.definator.client.DefinatorServiceProxy;
import org.leviatan.definator.core.admin.DefinatorAdminService;
import org.leviatan.definator.core.admin.DefinatorAdminServiceImpl;
import org.leviatan.definator.core.model.Field;
import org.leviatan.definator.core.model.Record;
import org.leviatan.definator.core.model.Table;


public class LocalServiceProxy extends DefinatorServiceProxy {
	
	private DefinatorAdminService service;

	public LocalServiceProxy() {
		this.service = DefinatorAdminServiceImpl.getService();
	}
	
	@Override
	public Map getFieldDefinitions() {
		return this.service.getFieldDefinitions();
	}

	@Override
	public Map getRecordDefinitions() {
		return this.service.getRecordDefinitions();
	}

	@Override
	public Map getTableDefinitions() {
		return this.service.getTableDefinitions();
	}

	@Override
	public Collection getRecordsFieldIds(String recId) {
		return this.service.getRecordsFieldIds(recId);
	}

	@Override
	public Collection getTablesRecordIds(String tblId) {
		return this.service.getTablesRecordIds(tblId);	
	}

	@Override
	public Field getFieldModel(String aId) {
		return this.service.getFieldModel(aId);
	}

	@Override
	public Record getRecordModel(String aId) {
		return this.service.getRecordModel(aId);
	}

	@Override
	public Table getTableModel(String aId) {
		return this.service.getTableModel(aId);
	}

	public String getFieldsRecordId(String fldId) {
		return this.service.getFieldsRecordId(fldId);
	}

	public String getRecordsTableId(String recId) {
		return this.service.getRecordsTableId(recId);
	}

	public Field addFieldModel(Field fld) {
		return this.service.addFieldModel(fld);
	}

	public Record addRecordModel(Record rec) {
		return this.service.addRecordModel(rec);
	}

	public Table addTableModel(Table tbl) {
		return this.service.addTableModel(tbl);
	}

	public void loadModels() {
		this.service.loadModels();
	}

	public boolean removeFieldModel(String fldId) {
		return this.service.removeFieldModel(fldId);
	}

	public boolean removeRecordModel(String recId) {
		return this.service.removeRecordModel(recId);
	}

	public boolean removeTableModel(String tblId) {
		return this.service.removeTableModel(tblId);
	}

	public void saveModels() {
		this.service.saveModels();
	}

	public void loadRegister() {
		this.service.loadRegister();
	}

	public void loadConfiguration(String filePath) {
		this.service.loadConfiguration(filePath);
	}
	
	
	
	
	// updates
	///////////////////////////////////////////////////////////////////////////

	public boolean updateFieldModel(String fldId, Field fldModel) {
		return this.service.updateFieldModel(fldId, fldModel);
	}

	public boolean updateRecordModel(String recId, Record recModel) {
		return this.service.updateRecordModel(recId, recModel);
	}

	public boolean updateTableModel(String tblId, Table tblModel) {
		return this.service.updateTableModel(tblId, tblModel);
	}

	@Override
	public boolean updateFieldLength(String fldId, int newLength) {
		return this.service.updateFieldLength(fldId, newLength);
	}

	@Override
	public boolean updateFieldModel(String fldId, String newName, 
			int newLength, String newType, String newRef) {

		return this.service.updateFieldModel(fldId, newName, newLength, newType, newRef);
	}

	@Override
	public boolean updateFieldName(String fldId, String newName) {
		return this.service.updateFieldName(fldId, newName);
	}

	public boolean updateFieldRecordRef(String fldId, String newRef) {
		return this.service.updateFieldRecordRef(fldId, newRef);
	}

	@Override
	public boolean updateFieldType(String fldId, String newType) {
		return this.service.updateFieldType(fldId, newType);
	}

	@Override
	public boolean updateRecordName(String recId, String newName) {
		return this.service.updateRecordName(recId, newName);
	}

	@Override
	public boolean updateTableName(String tblId, String newName) {
		return this.service.updateTableName(tblId, newName);
	}

	@Override
	public String createNewFieldModel() {
		return this.service.createNewFieldModel();
	}

	@Override
	public String createNewFieldModel(String name, int length, String type, String recRef) {
		return this.service.createNewFieldModel(name, length, type, recRef);
	}

	@Override
	public String createNewRecordModel() {
		return this.service.createNewRecordModel();
	}

	@Override
	public String createNewRecordModel(String name, String tblRef) {
		return this.service.createNewRecordModel(name, tblRef);
	}

	@Override
	public String createNewTableModel() {
		return this.service.createNewTableModel();
	}

	@Override
	public String createNewTableModel(String name) {
		return this.service.createNewTableModel(name);
	}

}
